package com.dwxt.cdms.controller;

import com.dwxt.cdms.base.Page;
import com.dwxt.cdms.service.EcgService;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/cdms/ecg")
@RestController
public class EcgController {

    @Autowired
    private EcgService ecgService;

    /**
     * @Description: 上传分析心电贴数据
     * @param map:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/upload")
    public BaseResult upload(@RequestBody Map map) {
        return ecgService.uploadEcgData(map);
    }

    /**
     * @Description: 按用户分组分页查询心电贴数据列表
     * @param page:
     * @param name:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectPageGroup")
    public BaseResult selectPageGroup(Page page, String name){
        return ecgService.selectPageGroup(page,name);
    }

    /**
     * @Description: 分页查询单个用户心电贴数据列表
     * @param page:
     * @param customerId:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectPageByCustomerId")
    public BaseResult selectPageByCustomerId(Page page,@RequestParam(required = true, name = "customerId") Integer customerId){
        return ecgService.selectPageByCustomerId(page,customerId);
    }

    /**
     * @Description: 通过id查询单条心电贴数据
     * @param id:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectById")
    public BaseResult selectById(Integer id){
        return ecgService.selectById(id);
    }

    /**
     * @Description: 根据客户id查询最新的一条数据
     * @param customerId:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/18
     */
    @RequestMapping("/selectLastByCustomerId")
    public BaseResult selectLastByCustomerId(@RequestParam(required = true, name = "customerId") Integer customerId){
        return ecgService.selectLastByCustomerId(customerId);
    }
}

